﻿using ApiManage.Core.Repository.MongoDB;
using ApiManage.Models.MongoMappings.Sys;
using Rhonin.Common.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace ApiManage.Service.Mongo.Sys.Impl
{
    [Component(LifeStyle.Singleton)]
    public class SysUserQueryService : ISysUserQueryService
    {
        private readonly ISysRepository<SysUser> _sysUserRepository;
        public SysUserQueryService(ISysRepository<SysUser> sysUserRepository)
        {
            _sysUserRepository = sysUserRepository;
        }

        public SysUser Get(Expression<Func<SysUser, bool>> where)
        {
            return _sysUserRepository.GetQuery().FirstOrDefault(where);
        }

        public List<SysUser> GetList(Expression<Func<SysUser, bool>> where)
        {
            return _sysUserRepository.GetQuery().Where(where).ToList();
        }
    }
}
